import QtQuick
import QtQuick3D
import QtQuick.Controls
import QtQuick.Dialogs
import QtQuick.Layouts
import QtQuick3D.Helpers

Window {
    id: mainwindow
    width: 860
    height: 480
    visible: true
    title: qsTr("MeshViewer")
    color: "grey"

    DropArea{
        anchors.fill: parent
        onDropped: {
            console.log(keys)
        }
    }

    // Setting
    ColumnLayout{
        spacing: 10
        Button{
            text: qsTr("BgColor")
            hoverEnabled: true
            ToolTip.delay: 300
            ToolTip.timeout: 3000
            ToolTip.visible: hovered
            ToolTip.text: qsTr("Change Background Color")
            onClicked: colorPicker.open()

            ColorDialog{
                id: colorPicker
                onAccepted: mainwindow.color = selectedColor
            }
        }
    }


    View3D {
        id: view3D
        anchors.fill: parent
        environment: sceneEnvironment
        SceneEnvironment {
            id: sceneEnvironment
            backgroundMode: SceneEnvironment.Color
            antialiasingQuality: SceneEnvironment.High
            antialiasingMode: SceneEnvironment.MSAA
        }

        Node {
            id: node
            DirectionalLight {
                id: directionalLight
            }

            PerspectiveCamera {
                id: camera
                eulerRotation.z: 0
                eulerRotation.y: 0
                eulerRotation.x: 0

                z: 0.00005
            }

            Model {
                id: model
                x: 0
                y: 0
                z: -200
                source: "#Cube"
                DefaultMaterial {
                    id: cubeMaterial
                    diffuseColor: "#4aee45"
                }
                materials: cubeMaterial
            }
        }

        WasdController {
             controlledObject: model
         }
    }
}
